import pygame
from game import Game


class Bullet2:
    def __init__(self, left: int, top: int, direction: str, speed: int):

        self.Bullet_image1 = pygame.image.load("Img/子弹右.png")
        self.Bullet_image2 = pygame.image.load("Img/子弹左.png")

        self.Bullet_image_right = pygame.transform.scale(self.Bullet_image1, (60, 15))
        self.Bullet_image_left = pygame.transform.scale(self.Bullet_image2, (60, 15))

        self.Bullet_rect = self.Bullet_image_left.get_rect()
        self.Bullet_rect.left = left
        self.Bullet_rect.top = top
        self.Bullet_speed = speed
        self.direction = direction

    def bullet_display(self):
        if self.direction == "left":
            Game.window.blit(self.Bullet_image_left, self.Bullet_rect)
        elif self.direction == "right":
            Game.window.blit(self.Bullet_image_right, self.Bullet_rect)

    def bullet_fire(self):
        if self.direction == "left":
            self.Bullet_rect.left -= self.Bullet_speed
        elif self.direction == "right":
            self.Bullet_rect.left += self.Bullet_speed
